package info.itloser.learnkotlindemo.ui.simple

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import info.itloser.learnkotlindemo.R
import info.itloser.learnkotlindemo.databinding.ActivityDialogsBinding

class DialogsActivity : AppCompatActivity(), View.OnClickListener {

    private lateinit var binding: ActivityDialogsBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActivityDialogsBinding.inflate(layoutInflater)
        setContentView(binding.root)


        binding.btnSimpleDialog.setOnClickListener(this)


    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.btn_simple_dialog -> {

                //简单的对话框
                AlertDialog.Builder(this).apply {

                    setTitle("对话框标题")
                    setMessage("对话框内容 对话框内容 对话框内容 对话框内容")

                    setPositiveButton("是") { _, _ ->
                        Toast.makeText(context, "点击了是! ", Toast.LENGTH_LONG).show()
                    }

                    setNegativeButton("否") { _, _ ->
                        Toast.makeText(context, "点击了否! ", Toast.LENGTH_LONG).show()
                    }

                    show()

                }


            }
        }
    }


}